"""Definition of the zhaoling content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtinfocontent import xtinfocontentMessageFactory as _

from my315ok.xtinfocontent.interfaces import Izhaoling
from my315ok.xtinfocontent.config import PROJECTNAME

zhaolingSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atapi.StringField(
        'category',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"info category"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'text',
        storage=atapi.AnnotationStorage(),
        widget=atapi.RichWidget(
            label=_(u"info content"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'phone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"phone"),
            description=_(u"contact phone"),
        ),
        required=True,
    ),


    atapi.StringField(
        'publisher',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"publisher"),
            description=_(u""),
        ),
        required=True,
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

zhaolingSchema['title'].storage = atapi.AnnotationStorage()
zhaolingSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(zhaolingSchema, moveDiscussion=False)


class zhaoling(base.ATCTContent):
    """announce the finding of lost property"""
    implements(Izhaoling)

    meta_type = "zhaoling"
    schema = zhaolingSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    category = atapi.ATFieldProperty('category')

    text = atapi.ATFieldProperty('text')

    phone = atapi.ATFieldProperty('phone')

    publisher = atapi.ATFieldProperty('publisher')


atapi.registerType(zhaoling, PROJECTNAME)
